package com.zhangsheng.client;

import com.zhangsheng.api.CommonResult;
import com.zhangsheng.entity.model.Order;
import com.zhangsheng.entity.model.Product;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 张晟
 * @version 1.0
 * @date 2023/2/20 14:21
 */
@FeignClient(value = "demo-mysql")
@Service
public interface MysqlFeignClient {
    @PostMapping("/product/master/add")
    CommonResult<Product> insertProduct(@RequestBody Product product);
    @GetMapping("/product/slave1/{id}")
    CommonResult<Product> selectBySlave1(@PathVariable("id") Integer id);
    @GetMapping("/product/slave2/{id}")
    CommonResult<Product> selectBySlave2(@PathVariable("id") Integer id);
    @GetMapping("/order/get/{id}")
    CommonResult<Order> getOrderById(@PathVariable("id") Integer orderId);
    @PostMapping("/order/close")
    CommonResult<Boolean> closeOrder(Order order);
    @PostMapping("/order/create")
    CommonResult<Order> insertOrder(@RequestBody Order order);
    @GetMapping("/order/slave1/getByPage")
    CommonResult<List<Order>> selectByPage(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                                           @RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize);

}
